import type { RouteRecordRaw } from "vue-router";
import AddOrEditAppPage from "@/views/add/AddOrEditAppPage.vue";
import AddOrEditQuestionPage from "@/views/add/AddOrEditQuestionPage.vue";
import AddOrEditScoringResultPage from "@/views/add/AddOrEditScoringResultPage.vue";
import { UserRoleEnum } from "@/enums";
import DoAnswerPage from "@/views/answer/DoAnswerPage.vue";
import AnswerResultPage from "@/views/answer/AnswerResultPage.vue";

export const appRoutes: Array<RouteRecordRaw> = [
  {
    path: "/app/add",
    name: "创建应用",
    component: AddOrEditAppPage,
    meta: {
      access: UserRoleEnum.USER,
    },
  },
  {
    path: "/app/edit/:id",
    name: "修改应用",
    props: true,
    component: AddOrEditAppPage,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/app/question/:appId",
    name: "编辑题目",
    component: AddOrEditQuestionPage,
    // 不设置这个 props, 在页面中拿不到 id 的值!
    props: true,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/app/scoring_result/:appId",
    name: "编辑评分策略",
    component: AddOrEditScoringResultPage,
    props: true,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/answer/do/:appId",
    name: "答题",
    component: DoAnswerPage,
    props: true,
    meta: {
      hideInMenu: true,
      access: UserRoleEnum.USER,
    },
  },
  {
    path: "/answer/result/:id",
    name: "答题结果",
    component: AnswerResultPage,
    props: true,
    meta: {
      hideInMenu: true,
      access: UserRoleEnum.USER,
    },
  },
];